<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>检测是否注册账号重名页面</title>
  </head>
  <body>
  <%
  try{
  Class.forName("org.mariadb.jdbc.Driver").newInstance();  
  //String username=request.getParameter("name");
  String username=request.getParameter("name");
  String url ="jdbc:mariadb://localhost:3306/imtshop?useUnicode=true&characterEncoding=utf-8"; 
  String user="root";
  String password="123456";
  String sql="select * from customer where username="+username+""; 
  Connection conn= DriverManager.getConnection(url,user,password); 
  Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 
  ResultSet rs=stmt.executeQuery(sql); 
  if(rs.first())
  {
  %>
  	out.println("您所注册用户名已经被人抢注了。。。。。");
  	
  <%} %>
  <%}
  	catch(Exception e)
  	{
  		out.println("数据库连接错误"+e.toString());
  	}
   %>
   <script>
   alert("没有重名哈，可以使用");
   window.location.href="register.jsp";
   	
   </script>
  
  </body>
</html>
